package com.boomshake.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.boomshake.entity.CommissionRecord;
import com.boomshake.vo.CommissionDetailVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 佣金记录Mapper接口
 */
@Mapper
public interface CommissionRecordMapper extends BaseMapper<CommissionRecord> {

    /**
     * 查询分销员佣金汇总信息
     * @param distributorId 分销员ID
     * @return 佣金汇总
     */
    Map<String, BigDecimal> selectCommissionSummary(@Param("distributorId") Long distributorId);

    /**
     * 分页查询分销员佣金记录
     * @param page 分页对象
     * @param distributorId 分销员ID
     * @return 佣金记录列表
     */
    IPage<CommissionDetailVO.CommissionRecordItem> selectCommissionRecords(Page<CommissionDetailVO.CommissionRecordItem> page,
                                                                           @Param("distributorId") Long distributorId);

    /**
     * 查询分销员佣金记录（不分页）
     * @param distributorId 分销员ID
     * @param limit 限制数量
     * @return 佣金记录列表
     */
    List<CommissionDetailVO.CommissionRecordItem> selectCommissionRecordsList(@Param("distributorId") Long distributorId,
                                                                              @Param("limit") Integer limit);

    /**
     * 更新佣金记录的提现状态
     * @param distributorId 分销员ID
     * @param withdrawalId 提现申请ID
     * @return 影响行数
     */
    int updateWithdrawalStatus(@Param("distributorId") Long distributorId, 
                               @Param("withdrawalId") Long withdrawalId);
} 